clear
dd = 30:136;
anni = 1870+dd;

% anni = (1900:2007)';
% yy = kron(anni,ones(4,1));
% qq = kron(ones(size(anni,1),1),([3 6 9 12])'); 
% DATE = [yy qq]; nn = datenum(DATE(:,1),DATE(:,2), 15); 
% results_var_gdp_m2_and_ar_ 
% results_var_infl_gdp_and_ar_ 
count = 0;
for j = dd
    count = count+1;
    j
    eval(['load ', 'results_var_infl_gdp_and_ar_13_02_cov1_0026_0026_con03_con03_',num2str(j)]);
    for h=1:3
        
        fore_var_tv{h}(j+h,1) = median(fore_var_tv_m_cum_gibb{h}(1,:));
        tt{h}(j+h,1)=true_cum{h}(end,1);
        fore_ar_tv{h}(j+h,1) = median(fore_ar_tv_m_cum_gibb{h}(1:end));
        aa=size(fore_ar_tv_m_cum_gibb{h},1);
        msfe_ar_tv{h}(:,j+h) = (fore_ar_tv_m_cum_gibb{h}-kron(true_cum{h}(end,1),ones(aa,1))).^2;
        %aa1=size(fore_var_tv_m_cum_gibb{h},2);
        msfe_var_tv{h}(:,j+h) = (fore_var_tv_m_cum_gibb{h}(1,:)'-kron(true_cum{h}(end,1),ones(aa,1))).^2;
        TRUE{h}(:,j+h)=true_cum{h}(end,1);
        msfe_lr_g{h}(:,j+h) = (LM(1,:)'-kron(true_cum{h}(end,1),ones(aa,1))).^2;
        msfe_lr_uni_g{h}(:,j+h) = (LMUni(1,:)'-kron(true_cum{h}(end,1),ones(aa,1))).^2;
   
        LR{h}(j+h,1)=LM_m(end,1);
        LR_uni{h}(j+h,1)=LM_uni_m(end,1);
    end
end
%anto = mean([TRUE{h}(28:end)'-fore_var_tv{h}(28:end,1) TRUE{h}(28:end)'-fore_ar_tv{h}(28:end,1) TRUE{h}(28:end)'-fore_var_rec_cum{h}(27+h:end,1) TRUE{h}(28:end)'-fore_ar_rec_cum{h}(27+h:end,1)].^2)
 
for h=1:3
msfe_LR{h}(:,1)=([TRUE{h}(30+h:end)'-LR{h}(30+h:end)].^2);
msfe_LR_uni{h}(:,1)=([TRUE{h}(30+h:end)'-LR_uni{h}(30+h:end)].^2);
end

win=9;
for h = 1:3
    for i= 1:size(msfe_ar_tv{h}(:,dd(1):end),1)
        m_ar{h}(i,:) =   filter(ones(1,win),1,msfe_ar_tv{h}(i,dd(1)+h:end));
        m_var{h}(i,:) =  filter(ones(1,win),1,msfe_var_tv{h}(i,dd(1)+h:end));
        m_lr_uni_g{h}(i,:) =  filter(ones(1,win),1,msfe_lr_uni_g{h}(i,dd(1)+h:end));
        m_lr_g{h}(i,:) =  filter(ones(1,win),1,msfe_lr_g{h}(i,dd(1)+h:end));
    end
    m_LR{h}(:,1) =  filter(ones(1,win),1,msfe_LR{h}(:,1));
    m_LR_uni{h}(:,1) =  filter(ones(1,win),1,msfe_LR_uni{h}(:,1));
end
 
for h = 1:3
    MSFE_ar{h} = m_ar{h}(:,win:end);
    MSFE_var{h} =  m_var{h}(:,win:end);
    MSFE_lr_uni{h} =  m_lr_uni_g{h}(:,win:end);
    MSFE_lr{h} =  m_lr_g{h}(:,win:end);
    
    
    MSFE_LR{h} =  m_LR{h}(win:end,:);
    MSFE_LR_uni{h} =  m_LR_uni{h}(win:end,:);
end
 
 
 figure(7);
 count = 0; 
 for h=[1 2 3]
     nn = anni(1:end-3+h);
    count = count+1;
 subplot(3,1,count);
ddate = nn(floor(win/2)+h):nn(floor(win/2)+h)+size(MSFE_var{h},2)-1;
plot(ddate,[ones(size(MSFE_var{h}+h,2),1) prctile(MSFE_var{h}./MSFE_ar{h},[16 50 84],1)']); axis([ddate(1)-h-1 ddate(end)+5-h -inf inf]); 

title(h)
set(gcf,'Color',[0.9725 0.9725 0.9725])
end
 
 